package com.gitee.huxing.mybatis.logging;

import org.apache.ibatis.logging.Log;

import java.util.function.Supplier;

/**
 * @Description: 日志管理
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.mybatis.logging
 * @ClassName: Logger
 * @Author: huxing
 * @DateTime: 2021-09-16 下午1:54
 */
public class Logger {

    private final Log log;

    Logger(Log log) {
        this.log = log;
    }

    public void error(Supplier<String> s, Throwable e) {
        log.error(s.get(), e);
    }

    public void error(Supplier<String> s) {
        log.error(s.get());
    }

    public void warn(Supplier<String> s) {
        log.warn(s.get());
    }

    public void debug(Supplier<String> s) {
        if (log.isDebugEnabled()) {
            log.debug(s.get());
        }
    }

    public void trace(Supplier<String> s) {
        if (log.isTraceEnabled()) {
            log.trace(s.get());
        }
    }
}
